/**
 * 
 */
package com.populardata;


/**
 * These are the types a zip code in the AddressLookup may be.
 * This enum is not a part of the Frazer domain model; it is
 * an artifact of the AddressLookup data.
 * 
 * @author Bill Shirley, Frazer, Ltd.
 * @see AddressLookup
 */
public enum ZipClass {
	STANDARD,
	UNIQUE,
	PO_BOX_ONLY,
	MILITARY,
	UNDEFINED;
	
	/**
	 * Converts a string similar to the above values into the actual value.
	 * Spaces can replace the underscores and it is case insensitive.
	 * 
	 * @param value
	 * @return
	 */
	public static ZipClass convertString(String value) {
		if (value == null)
			return UNDEFINED;
		
		value = value.replace(" ", "_").toUpperCase();
		
		if (value.equals("UNIQUE"))
			return UNIQUE;
		
		if (value.equals("STANDARD"))
			return STANDARD;
		
		if (value.equals("PO_BOX_ONLY"))
			return PO_BOX_ONLY;
		
		if (value.equals("MILITARY"))
			return MILITARY;
		
		return UNDEFINED;
	}
}
